package de.koller.renderEngine.render;

import de.koller.oceanFramework.gl.util.ViewUtil;
import de.koller.oceanFramework.tree.Sea3X;
import de.koller.renderEngine.RenderEngine;
import de.koller.renderEngine.physics.CubeData;
import de.koller.renderEngine.physics.PhysicsRoot;
import de.koller.renderEngine.physics.Szene;
import de.koller.renderEngine.render.geom.CubeRenderer;
import org.lwjgl.opengl.GL11;

public class RERendering extends Sea3X implements IRenderObj {
	
	private final PhysicsRoot proot = Szene.gen();
	private final CubeRenderer cubeRenderer = new CubeRenderer();
	
	@Override
	protected void init() {
		super.init();
	
		ViewUtil.initOrtho( RenderEngine.HD_W, RenderEngine.HD_H );
		
		GL11.glEnable( GL11.GL_CULL_FACE );
		GL11.glCullFace( GL11.GL_FRONT );

		GL11.glEnable( GL11.GL_DEPTH_TEST );
		GL11.glDepthFunc( GL11.GL_LEQUAL );
		
		GL11.glAlphaFunc( GL11.GL_GREATER, 0.1f );
		GL11.glEnable( GL11.GL_ALPHA_TEST );
	}
	
	@Override
	public void renderSlow() {
	
	}

	@Override
	public void renderFast() {
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
		
		GL11.glPushMatrix();
		GL11.glScalef( 10, 10, 0 );
		
		proot.update();
		for( CubeData c : proot )
			cubeRenderer.render( c.x, c.y, c.w, c.h, c.r );
		
		GL11.glPopMatrix();
	}
	
	private void saveScreen() {
		
	}
	
}
